import SimpleITK as sitk
import numpy as np
import copy
from itertools import *
from math import *
import os
from PyQt5.Qt import QThread, pyqtSignal
import sys
from MR_stitch_final import *


class thread_fuse(QThread):
    signal_info = pyqtSignal(str)
    signal_finished = pyqtSignal(np.ndarray)
    # 定义一个自定义信号 signal_image
    signal_image = pyqtSignal(np.ndarray)
    def __init__(self, OriData_path):
        super().__init__()
        self.OriData_path = OriData_path

    def run(self):
        # 执行配准
        self.signal_info.emit("读入数据并初始化中......")
        #获取文件名称以及数量
        dcms, dcms_num = read_dcms(self.OriData_path)
        self.signal_info.emit("数据全部读入成功，初始化已结束")
        self.signal_info.emit("开始配准：")
        #调用拼接程序
        result = fusion(dcms, dcms_num)
        self.signal_info.emit("配准融合已成功完成！")
        self.signal_image.emit(result)
